Skip to main content

zsh 记录


# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi

# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH

# Path to your oh-my-zsh installation.
export ZSH="$HOME/.oh-my-zsh"

# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
ZSH_THEME="powerlevel10k/powerlevel10k" #agnoster robbyrussell powerlevel10k/powerlevel10k Powerlevel9k/powerlevel9k passion




# Set list of themes to pick from when loading at random
# Setting this variable when ZSH_THEME=random will cause zsh to load
# a theme from this variable instead of looking in $ZSH/themes/
# If set to an empty array, this variable will have no effect.
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )

# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"

# Uncomment the following line to use hyphen-insensitive completion.
# Case-sensitive completion must be off. _ and - will be interchangeable.
# HYPHEN_INSENSITIVE="true"

# Uncomment one of the following lines to change the auto-update behavior
# zstyle ':omz:update' mode disabled # disable automatic updates
# zstyle ':omz:update' mode auto # update automatically without asking
# zstyle ':omz:update' mode reminder # just remind me to update when it's time

# Uncomment the following line to change how often to auto-update (in days).
# zstyle ':omz:update' frequency 13

# Uncomment the following line if pasting URLs and other text is messed up.
# DISABLE_MAGIC_FUNCTIONS="true"

# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"

# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"

# Uncomment the following line to enable command auto-correction.
# ENABLE_CORRECTION="true"

# Uncomment the following line to display red dots whilst waiting for completion.
# You can also set it to another string to have that shown instead of the default red dots.
# e.g. COMPLETION_WAITING_DOTS="%F{yellow}waiting...%f"
# Caution: this setting can cause issues with multiline prompts in zsh < 5.7.1 (see #5765)
# COMPLETION_WAITING_DOTS="true"

# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"

# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# You can set one of the optional three formats:
# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# or set a custom format using the strftime function format specifications,
# see 'man strftime' for details.
# HIST_STAMPS="mm/dd/yyyy"

# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder

# Which plugins would you like to load?
# Standard plugins can be found in $ZSH/plugins/
# Custom plugins may be added to $ZSH_CUSTOM/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(
git
iterm2
bundler
dotenv
vscode
macos
macports
man
ruby
python
composer
adb
cp
z
zsh-syntax-highlighting
zsh-autosuggestions
)
#autojump

source $ZSH/oh-my-zsh.sh

# User configuration

# export MANPATH="/usr/local/man:$MANPATH"

# You may need to manually set your language environment
# export LANG=en_US.UTF-8

# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
# export EDITOR='vim'
# else
# export EDITOR='mvim'
# fi

# Compilation flags
# export ARCHFLAGS="-arch x86_64"

# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"

#设置历史命令记录数
export HISTSIZE=5000
#记录历史文件大小
export HISTFILESIZE=450
#忽略重复
export HISTCONTROL=ignoredups

# source $ZSH/templates/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
# source $ZSH/templates/zsh-autosuggestions/zsh-autosuggestions.zsh

export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo'





#JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home
# JAVA_HOME=/Users/arick/Library/Java/JavaVirtualMachines/azul-17.0.4.1/Contents/Home
# PATH=$JAVA_HOME/bin:$PATH:/opt/metasploit-framework/bin
# CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar
# export JAVA_HOME
# export PATH
# export CLASSPATH

# export GRADLE_HOME=/Users/arick/.gradle/gradle-7.4.2

# PATH=$GRADLE_HOME/bin:$PATH


# M2_HOME=~/.g/maven-3.8.4
# PATH=$PATH:$M2_HOME/bin


# export ANDROID_HOME=~/android/sdk
# export PATH=${PATH}:${ANDROID_HOME}/platform-tools
# export PATH=${PATH}:${ANDROID_HOME}/tools
# export PATH=${PATH}:${ANDROID_HOME}/build-tools/28.0.1


# #export all_proxy=socks5://127.0.0.1:7890
# #export http_proxy=http://127.0.0.1:7890
# #export https_proxy=http://127.0.0.1:7890

function proxy_on() {
export http_proxy=http://127.0.0.1:7890
export https_proxy=$http_proxy
export all_proxy=socks5://127.0.0.1:7890
export no_proxy="localhost,127.0.0.1,localaddress,.localdomain.com"
export ftp_proxy=$http_proxy
export rsync_proxy=$http_proxy
export HTTP_PROXY=$http_proxy
export HTTPS_PROXY=$http_proxy
export FTP_PROXY=$http_proxy
export RSYNC_PROXY=$http_proxy
echo -e "终端代理已开启。"
}

function proxy_off(){
unset http_proxy https_proxy all_proxy ftp_proxy rsync_proxy
echo -e "终端代理已关闭。"
}


# export PATH=~/.g/flutter/bin:$PATH
# export PUB_HOSTED_URL=https://pub.flutter-io.cn
# export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn




# export THEOS=/opt/theos
# export PATH=/opt/theos/bin/:$PATH

# export MonkeyDevPath=/opt/MonkeyDev
# #export MonkeyDevDeviceIP=
# export PATH=/opt/MonkeyDev/bin:$PATH

# #go语言安装主根目录
# export GOROOT="${HOME}/.vm/versions/go_versions/go"
# #GOPATH 是自己的go项目路径,自定义设置
export GOPATH=~/go
export PATH="$GOPATH/bin:${HOME}/.vm/versions/go_versions/go/bin:$PATH"
# #GOBIN 当我们使用go install命令编译后并且安装的二进制程序目录
export GOBIN=$GOPATH/bin
# #下载go的网址
export G_MIRROR=https://golang.google.cn/dl/
# # 启用 Go Modules 功能
export GO111MODULE=on
# # 配置 GOPROXY 环境变量
export GOPROXY=https://goproxy.cn,direct

eval "$(mcfly init zsh)"


# #rust 镜像
# export RUSTUP_DIST_SERVER="https://rsproxy.cn"
# export RUSTUP_UPDATE_ROOT="https://rsproxy.cn/rustup"

# export PATH=$PATH:$GOROOT/bin:$GOBIN:~/nushell


# .net mono
# export PATH="/Library/Frameworks/Mono.framework/Versions/6.12.0/bin:$PATH"

#conda
# __conda_setup="$('/opt/homebrew/Caskroom/miniconda/base/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
# if [ $? -eq 0 ]; then
# eval "$__conda_setup"
# else
# if [ -f "/opt/homebrew/Caskroom/miniconda/base/etc/profile.d/conda.sh" ]; then
# . "/opt/homebrew/Caskroom/miniconda/base/etc/profile.d/conda.sh"
# else
# export PATH="/opt/homebrew/Caskroom/miniconda/base/bin:$PATH"
# fi
# fi
# unset __conda_setup



# vm_envs start
if [ -z $VM_DISABLE ]; then
. /Users/arick/.vm/vm_env.sh
fi
# vm_envs end

export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"

# >>> mamba initialize >>>
# !! Contents within this block are managed by 'mamba init' !!
export MAMBA_EXE='/Users/arick/.micromamba/bin/micromamba';
export MAMBA_ROOT_PREFIX='/Users/arick/micromamba';
__mamba_setup="$("$MAMBA_EXE" shell hook --shell zsh --root-prefix "$MAMBA_ROOT_PREFIX" 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__mamba_setup"
else
alias micromamba="$MAMBA_EXE" # Fallback on help from mamba activate
fi
unset __mamba_setup
# <<< mamba initialize <<<

# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/Users/arick/micromamba/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/Users/arick/micromamba/etc/profile.d/conda.sh" ]; then
. "/Users/arick/micromamba/etc/profile.d/conda.sh"
else
export PATH="/Users/arick/micromamba/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<

# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh


插件

$ZSH_CUSTOM/plugins/zsh-autosuggestions 位置

cd ~/.oh-my-zsh/custom/plugins

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git

git clone git://github.com/zsh-users/zsh-autosuggestions

vim .zshrz

plugins=(
git
zsh-syntax-highlighting
zsh-autosuggestions
)

主题 颜色

GitHub - altercation/solarized: precision color scheme for multiple applications (terminal, vim, etc.) with both dark/light modes

字体

[fonts/Meslo Slashed/Meslo LG M Regular for Powerline.ttf at master · powerline/fonts · GitHub](https://github.com/powerline/fonts/blob/master/Meslo Slashed/Meslo LG M Regular for Powerline.ttf)

打开iTerm2,打开Preferences配置界面,然后Profiles -> Text -> Font -> Chanage Font,选择 Meslo LG M Regular for Powerline 字体

透明背景

iTerm2 -> Preferences -> Profiles -> Window -> Transparency

command + enter 进入与返回全屏模式
command + t 新建标签
command + w 关闭标签
command + 数字 command + 左右方向键 切换标签
command + enter 切换全屏
command + f 查找
command + d 水平分屏
command + shift + d 垂直分屏
command + option + 方向键 command + [ 或 command + ] 切换屏幕
command + ; 查看历史命令
command + shift + h 查看剪贴板历史
ctrl + u 清除当前行
ctrl + l 清屏
ctrl + a 到行首
ctrl + e 到行尾
ctrl + f/b 前进后退
ctrl + p 上一条命令
ctrl + r 搜索命令历史